package com.example.windows8.newef.dialog;

import android.app.Activity;
import android.content.Intent;
import android.view.View;

import com.example.windows8.newef.R;
import com.example.windows8.newef.activity.AddFriendActivity;
import com.example.windows8.newef.activity.AddHardActivity;
import com.zaaach.toprightmenu.MenuItem;
import com.zaaach.toprightmenu.TopRightMenu;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by windows8 on 2017/11/28.
 */

public class AddMainDialog extends TopRightMenu {
    public AddMainDialog(final Activity context, View v) {
        super(context);
        List<MenuItem> menuItems = new ArrayList<>();
        this
                .setHeight(240)     //默认高度480
                //.setWidth(200)      //默认宽度wrap_content
                .showIcon(false)     //显示菜单图标，默认为true
                .dimBackground(true)        //背景变暗，默认为true
                .needAnimationStyle(true)   //显示动画，默认为true
                .setAnimationStyle(R.style.TRM_ANIM_STYLE)
                .addMenuList(menuItems)
                .addMenuItem(new MenuItem( "添加好友"))
                .addMenuItem(new MenuItem( "添加硬件"))
                .setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() {
                    @Override
                    public void onMenuItemClick(int position) {
                        switch (position){
                            case 0:
                                Intent addf = new Intent(context, AddFriendActivity.class);
                                context.startActivity(addf);
                                break;
                            case 1:
                                Intent addh = new Intent(context, AddHardActivity.class);
                                context.startActivity(addh);
                                break;
                        }
                    }
                })
                .showAsDropDown(v,-100,0);	//带偏移量
    }
}
